Scripting Library

Important Scripting Information

Scripting requires vcredist2015 (https://www.microsoft.com/en-us/download/details.aspx?id=48145) to be installed on the Server running the Web Service or the PC running the Web Console. If you receive an LSE while trying to execute a script on the client’s side that works internally, it is probably because they do not have vcredist2015 installed on their server or local machine. There are x64 and x86 versions of the software, so be sure to install the correct version for the computer.

  • To install on the server:
    • Stop the Web Service.
    • Install the software.
    • Restart the service.
    • This should not require a restart of the server.
  • To install on the local machine:
    • Quit the Web Console.
    • Install the software.
    • Restart the console.

Some Notes:

  1. On using the RemoveRow function: In DEACOM scripting the RemoveRow() function takes a row as it's parameter, not an integer indicating the row number. So if you want to delete the first row of a table, you can not use DataTable.RemoveRow(0), you have to use DataTable.RemoveRow(DataTable.GetRow(0)) because you need the row object as the parameter, not the row number.
  2. On using the Script Engine for Externals and Grid Scripts: Beginning in version 17.01.026, MemoryEnvironment has been added to ScriptEngine instantiation to enable the Globals object in External and Grid Scripts and SessionVariables have been added to instantiation of ScriptEngine to External and Grid scripts.
  3. Beginning in version 17.04.004, Script windows support light/dark themes

To add an External script:

  1. Navigate to Tools > Externals > Add
  2. Give it a name, select Script type, add script to Script memo field.
  3. Globals:
    1. Add Externals Script with the following script: Script.LogConsole(Globals.Username);
    2. Run the script, verify in the Console window that your Username is printed.
  4. SessionVariables:
    1. Add Externals Script with the following script:
    2. Session.Variables.MyVar = "Hello World!";
    3. Script.LogConsole("Reading/writing Session Variable: " + Session.Variables.MyVar);
    4. Run the script, verify in the Console window that "Hello World!" is printed.
  5. Add Grid Script to any grid layout.
    • var lvGridData = Parameters.Results; //-- Create scripted columns (s_) lvGridData.AddStringColumn('s_Session_Var'); for(var lnX = 0; lnX < lvGridData.Count; lnX++){     var lrX = lvGridData.GetRow(lnX);         try     {         var lcTemp = Session.Variables.MyVar;                 lrX.SetString('s_Session_Var', lcTemp);     }     catch(e)     {         lrX.SetString('s_Session_Var', 'Session not found');     }  }
  6. Save. Make sure to close the form and re-open so the layout changes are loaded.
  7. Modify the form layout again, this time add the new column to the layout, s_Session_Var. Caption: Test, Width: 10
  8. Save. Close, re-open
  9. Verify that the Test column has the value from the session variable in the previous step, "Hello World!"
  10. If not, run the SessionVariable step above and then refresh the grid.